package com.lili.order.controller.aftersale;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lili.common.result.Result;
import com.lili.model.order.entity.aftersale.AfterSale;
import com.lili.order.service.aftersale.AfterSaleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags = "售后管理")
@RestController
@RequestMapping("/admin/order/afterSale")
  public class AfterSaleController{
    @Autowired
    AfterSaleService afterSaleService;
    @PostMapping("/save")
    @ApiOperation("添加售后")
    public Result save(@RequestBody AfterSale afterSale){
        int rs= afterSaleService.save(afterSale);
        return rs==1? Result.ok():Result.fail();
    }
    @DeleteMapping("/delete")
    @ApiOperation("删除售后")
    public Result delete(String id){
        int rs= afterSaleService.delete(id);
        return rs==1? Result.ok():Result.fail();
    }
    @PutMapping("/update")
    @ApiOperation("修改售后")
    public Result update(@RequestBody AfterSale afterSale){
        int rs= afterSaleService.update(afterSale);
        return rs==1? Result.ok():Result.fail();
    }
    @PostMapping("/queryByPage")
    @ApiOperation("查询所有售后")
    public Result queryByPage(@RequestBody Map map){
        Page<AfterSale> page = afterSaleService.queryByPage(map);
        return Result.ok(page);
    }
    @GetMapping("/queryById")
    @ApiOperation("查询单个售后")
    public Result queryById(String id){
        AfterSale afterSale = afterSaleService.queryById(id);
        return Result.ok(afterSale);
    }

  }